﻿using Anke.SHManage.MSSQLDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class LS_JJPFModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
          
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
              
        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
          
            //引用DropDownListBLL的 GetCenterOnaspx获取分中心，GetStationOnaspx获取分站。使用ControlHelper.SetDropDownList赋值给DropDownList
            //DropDownListBLL dbll = new DropDownListBLL();
            //ControlHelper.SetDropDownList(DropDownList_Center, dbll.GetCenterOnaspx(), "-1");//分中心
            //ControlHelper.SetDropDownList(DropDownList_Station, dbll.GetStationOnaspx("-1"), "-1");//分站

            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);
            string eventType = Convert.ToString(this.txtPatientVersion.Text);
            string txtCenter = Convert.ToString(this.Center.Text);
            string stationID = Convert.ToString(this.Station.Text);
            // string txtCenter = Convert.ToString(this.DropDownList_Center.SelectedValue);
            //// string txtCenter = Convert.ToString(DropDownList_Center.Text);
            // string stationID = Convert.ToString(this.DropDownList_Station.SelectedValue);
            string agentID = Convert.ToString(this.txtAgentWorkID.Text);
            string doctorAndNurse = Convert.ToString(this.txtDoctorAndNurse.Text);
            string txtDiseasesClassification = Convert.ToString(this.txtDiseasesClassification.Text);
            string txtIllnessClassification = Convert.ToString(this.txtIllnessClassification.Text);
            string txtDeathCase = Convert.ToString(this.txtDeathCase.Text);
            string txtMeasures = Convert.ToString(this.txtMeasures.Text);
            string txtFirstAidEffect = Convert.ToString(this.txtFirstAidEffect.Text);
            string txtFirstImpression = Convert.ToString(this.txtFirstImpression.Text);
            string txtSendAddress = Convert.ToString(this.txtSendAddress.Text);
            string Rosc = Convert.ToString(this.HiddenForRosc.Value);
            string formedConsent = Convert.ToString(this.HiddenForFormedConsent.Value);
            string illnessForecast = Convert.ToString(this.txtIllnessForecast.Text);
              string ScoreType = Convert.ToString(this.HiddenForScore.Value);
            string start1 = beginTime.ToString();
            string end1 = endTime.ToString();

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/" + "LS_JJPF.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });

            LSDAL dals = new LSDAL();     
                   
                    DataTable dtdl = dals.Get_LS_JJPF(beginTime, endTime, eventType, stationID, agentID, doctorAndNurse,
                  txtCenter, txtDiseasesClassification, txtIllnessClassification, txtDeathCase, txtMeasures, txtFirstAidEffect,
                  txtFirstImpression, txtSendAddress, formedConsent, ScoreType);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForLS_JJPF", dtdl));
                 
           
            
            this.ReportViewer1.LocalReport.Refresh();
        }
        //分中心的下拉框选择后，触发以下事件，根据分中心取出所有分站的内容。
        //protected void DropDownList_Center_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    string centerCode = DropDownList_Center.SelectedValue;
        //    DropDownList_Station.Items.Clear();
        //    DropDownListBLL sbll = new DropDownListBLL();
        //    ControlHelper.SetDropDownList(DropDownList_Station, sbll.GetStationOnaspx(DropDownList_Center.SelectedValue), "-1");//分站
        //}
    }
}